-
Notifications
You must be signed in to change notification settings - Fork 20
Updated ocr3 Metadata type to include Encoding and Decoding #1160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
15fe47d
to
5ca7af8
Compare
return buf.Bytes(), nil | ||
} | ||
|
||
const MetadataLen = 1 + 32 + 4 + 4 + 4 + 32 + 10 + 20 + 2 // =109 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth repeating these details here 🤷
const MetadataLen = 1 + 32 + 4 + 4 + 4 + 32 + 10 + 20 + 2 // =109 | |
// 1B Version, 32B ExecutionID, 4B Timestamp, 4B DONID, 4B DONConfigVersion, | |
// 32B WorkflowID, 10B WorkflowName, 20B WorkflowOwner, 2B ReportID | |
const MetadataLen = 1 + 32 + 4 + 4 + 4 + 32 + 10 + 20 + 2 // =109 |
} | ||
|
||
// appendAttrsRequired appends required attributes to the attribute key-value list | ||
func (e *protoEmitter) appendAttrsRequired(ctx context.Context, m proto.Message, attrKVs []any) []any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context is unused
func (e *protoEmitter) appendAttrsRequired(ctx context.Context, m proto.Message, attrKVs []any) []any { | |
func (e *protoEmitter) appendAttrsRequired(m proto.Message, attrKVs []any) []any { |
attrKVs = appendRequiredAttrEntity(m, attrKVs) | ||
attrKVs = appendRequiredAttrDomain(m, attrKVs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we align with the build in append
func, by passing attrKVs
as the first argument?
attrKVs = appendRequiredAttrEntity(m, attrKVs) | |
attrKVs = appendRequiredAttrDomain(m, attrKVs) | |
attrKVs = appendRequiredAttrEntity(attrKVs, m) | |
attrKVs = appendRequiredAttrDomain(attrKVs, m) |
// Needs to be an URI (Beholder requirement) | ||
val := toSchemaPath(m, basePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to be doing this for the caller? This is the only use of m
and basePath
, so we could just accept the val
as a parameter, which is more flexible/reusable.
for i := 0; i < len(attrKVs); i += 2 { | ||
if attrKVs[i] == key { | ||
return attrKVs | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make some kind of helper for this repeated block:
for i := 0; i < len(attrKVs); i += 2 { | |
if attrKVs[i] == key { | |
return attrKVs | |
} | |
} | |
if containsKey(attrKVs, key) { | |
return attrKVs | |
} |
func containsKey(attrKVs []any, key string) bool {
for i := 0; i < len(attrKVs); i += 2 {
if attrKVs[i] == key {
return true
}
}
Requires
Supports